package com.example.demo.service;

import java.util.List;

import javax.annotation.Resource;
import javax.transaction.Transactional;

import org.springframework.stereotype.Service;

import com.example.demo.entity.Car;
import com.example.demo.repository.CarRepository;

@Service
public class CarService {
	
	@Resource
	private CarRepository carRepository;

	
	public Car findOne(Integer id) {
		return carRepository.findOne(id);
	}
	
	
	public List<Car> findAll() {
		return carRepository.findAll();
	}
	
	@Transactional
	public Car add(Car car) {
		return carRepository.save(car);
	}
	@Transactional
	public void removeById(Integer id) {
		carRepository.delete(id);
	}
	@Transactional
	public Car update(Car car) {
		return carRepository.save(car);
	}
	
}
